PLEX-3129 LP skip blocks#501
Conversation
|
2af46d9 to
8b39b14
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds an operator/API mechanism to fast-forward the EVM LogPoller to a new finalized checkpoint (“skip blocks”), including DB-side pruning and the necessary concurrency/atomicity safeguards.
Changes:
- Exposes a relayer-level method to request a LogPoller fast-forward to a target block.
- Adds LogPoller
SkipToBlockplus a new ORM transactional method to prune logs/blocks and store a new finalized checkpoint anchor. - Adds/updates tests and mocks to cover checkpoint storage, transactional behavior, and SkipToBlock edge cases.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/relay/evm_service.go | Adds LPSkipToBlock API surface that delegates to the chain LogPoller. |
| pkg/logpoller/orm.go | Introduces StoreNewFinalizedCheckpoint and refactors delete/insert helpers for transactional reuse. |
| pkg/logpoller/orm_test.go | Adds coverage for checkpoint storage semantics and verifies transactional DS usage. |
| pkg/logpoller/observability.go | Wires StoreNewFinalizedCheckpoint through the observed ORM wrapper for metrics/tracing. |
| pkg/logpoller/mocks/log_poller.go | Extends the LogPoller mock with SkipToBlock. |
| pkg/logpoller/mock_orm_test.go | Extends the ORM mock with StoreNewFinalizedCheckpoint. |
| pkg/logpoller/log_poller.go | Implements SkipToBlock, adds runMu coordination, and refactors main loop tick handlers. |
| pkg/logpoller/log_poller_internal_test.go | Adds unit tests for SkipToBlock behavior and error handling. |
| pkg/logpoller/disabled.go | Implements SkipToBlock on the disabled LogPoller to return ErrDisabled. |
Files not reviewed (2)
- pkg/logpoller/mock_orm_test.go: Generated file
- pkg/logpoller/mocks/log_poller.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a8e4588 to
6207437
Compare
| err = validateHead((*evmtypes.Head)(anchorHead)) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to validate anchor block %d: %w", anchorBlockNumber, err) | ||
| } | ||
|
|
||
| anchorBlock := finalizedHeadToBlock((*evmtypes.Head)(anchorHead)) |
There was a problem hiding this comment.
nit, this is getting casted twice, I'd just convert it first and change validateHead to validate the block struct that finalizedHeadToBlock returns
There was a problem hiding this comment.
Changing the type that validate Head accepts requires changes in all other places that use it, which creates a ripple effect.
Fixed double cast by introduction of new method
| } | ||
|
|
||
| minBlockToPrune := anchorBlockNumber | ||
| if latest != nil { |
There was a problem hiding this comment.
shouldn't an error be returned if latest finalized block can't be confirmed?
There was a problem hiding this comment.
If the latest block is missing, it just means the DB is empty.
It can occur only if the main run has not ticked yet, which is unlikely. But even if it occurs, we'll save the finalized block as a checkpoint. Thus, the LP state will be valid.
# Conflicts: # go.mod # go.sum
Expose the API to force LP to fast-forward to a new finalized checkpoint.